Skip to content

Avoid coercing structuredClone failures - #58221

Open
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/fix-structured-clone-error-coercion
Open

Avoid coercing structuredClone failures#58221
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/fix-structured-clone-error-coercion

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary:

The structured-clone polyfill stringifies unsupported inputs while building its error message, letting user coercion replace DataCloneError with an arbitrary exception. Centralize the duplicate error construction and use a value-independent message so rejection performs no user callback.

Fixes #58220.

Changelog:

[GENERAL] [FIXED] - Avoid invoking user coercion while rejecting unsupported structuredClone values.

Test Plan:

  • Exact Hermes baseline let throwing Symbol.toPrimitive hooks replace the expected DOMException for a function and WeakMap.
  • Fixed focused Fantom suite: 33/33 passed.
  • Fresh yarn flow-check: 0 errors.
  • Targeted ESLint, Prettier, and git diff --check passed.

The non-standard message text becomes value-independent; exception type, name, and code remain DOMException / DataCloneError. No UI change; screenshots are not applicable.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 30, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

structuredClone coerces rejected values while creating DataCloneError

1 participant